<template>
  <div class="nav-header">
    <el-icon class="fold">
      <grid class="grid" @click="handleFoldClick" />
    </el-icon>
    <div class="cont">
      <breadcrumb :breadcrumbs="breadcrumbs"></breadcrumb>
      <nav-userinfo></nav-userinfo>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useRoute } from 'vue-router';
import { useStore } from '@/store';

import { ref, defineEmits, computed } from 'vue';
import { Grid } from '@element-plus/icons-vue';
import NavUserinfo from './nav-userinfo.vue';
import Breadcrumb from '@/base-ui/breadcrumb';

// import type { IBreadCrumb } from '@/base-ui/breadcrumb';
import { pathMapToBreadCrumb } from '@/utils/map.menus';

const route = useRoute();
const store = useStore();

const emit = defineEmits(['handleFoldClick']);

const isFold = ref(false);

const breadcrumbs = computed(() => {
  return pathMapToBreadCrumb(store.state.login.userMenus, route.path);
});

const handleFoldClick = () => {
  isFold.value = !isFold.value;
  emit('handleFoldClick', isFold.value);
};
</script>

<style lang="less" scoped>
.nav-header {
  height: 100%;
  display: flex;
  align-items: center;
  .fold {
    width: 25px;
    height: 25px;
    vertical-align: top;
    .grid {
      width: 100%;
      height: 100%;
    }
  }
  .cont {
    width: 100%;
    padding-left: 20px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
}
</style>
